<template>
	<view class="page">
		<view class="">换源</view>
		<radio-group @change="radioChange">
			<label v-for="(item, index) in sources" :key="index">
				<view style="margin-top: 4px;display: flex;justify-content: flex-start;align-items: center;">
					<radio :value="item.value" :checked="item.value===curSource.value" />
					<text>{{item.label}}</text>
				</view>
			</label>
		</radio-group>

		<view class="">
			<button type="default" @tap="readHistory">阅读记录</button>
		</view>
	</view>
</template>

<script>
	import {
		mapGetters,
		mapMutations
	} from 'vuex'

	export default {
		data() {
			return {}
		},
		computed: {
			...mapGetters({
				'sources': 'get_sources',
				'curSource': 'get_curSource'
			}),
		},
		onLoad() {},
		methods: {
			...mapMutations(['set_curSource']),
			radioChange(e) {
				let source = this.sources.filter(item => item.value === e.detail.value)
				if (source.length > 0) {
					this.set_curSource(source[0])
				}
			},
			readHistory() {
				uni.navigateTo({
					url: '/pages/me/readHistory'
				})
			}
		}
	}
</script>
<style>
	.page {
		padding: 20rpx;
	}

	.desc {
		margin-top: 30rpx;
		margin-bottom: 10rpx;
		color: #ff0000;
		font-size: 12px;
		white-space: pre-line;
	}

	.button {
		margin-bottom: 20rpx;
	}

	.flex-between {
		display: flex;
		justify-content: space-between;
		align-items: center;
	}
</style>
